#!/usr/bin/env python
# *-* coding: utf-8 *-*
from django.shortcuts import render_to_response
from django.template import RequestContext
from django import forms
from django.core.mail import send_mail
from django.http import HttpResponseRedirect
from forms import FormContato, FormRegistro
from django.contrib.auth.decorators import login_required
def contato(request):
	if request.method == 'POST':
		form = FormContato( request.POST )
		if form.is_valid():
			form.enviar()
			mostrar = 'Contato enviado'
	else:form = FormContato()
	
	return render_to_response(
		'contato.html',
		locals(),
		context_instance = RequestContext(request),
)

#View albuns
#Define a pagina que sera usada pela url '/albuns/'
def albuns(request):
	return render_to_response(
	'albuns.html',
	locals(),
	context_instance = RequestContext(request),
	)
	
#views registrar
#Define a pagina para o registro de novos usuarios
@login_required
def registrar(request):
	if(request.method == 'POST'):
		form = FormRegistro(request.POST)
		
		if(form.is_valid()):
			novo_usuario = form.save()
			return HttpResponseRedirect('/')
	else:
		form  = FormRegistro()
	return render_to_response(
		'registrar.html',
		locals(),
		 context_instance=RequestContext(request),
		)
